package com.lanyun.aicorrectassistant.controller.admin.userApiKey;

import com.lanyun.aicorrectassistant.basic.bean.PageResult;
import com.lanyun.aicorrectassistant.basic.bean.Result;
import com.lanyun.aicorrectassistant.controller.admin.userApiKey.vo.UserApiKeyRequestPageVO;
import com.lanyun.aicorrectassistant.controller.admin.userApiKey.vo.UserApiKeyRequestVO;
import com.lanyun.aicorrectassistant.controller.admin.userApiKey.vo.UserApiKeyResponseVO;
import com.lanyun.aicorrectassistant.domain.userApiKey.UserApiKeyDomainService;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


/**
 * 用户API密钥存储表控制器
 *
 * @author Jqchan
 * @version 1.0
 * @date 2025-05-29 23:26:37
 */
@RequestMapping("/api-admin/userApiKey")
@RestController("adminUserApiKeyController")
@Slf4j
public class UserApiKeyController {

    @Resource
    private UserApiKeyDomainService userApiKeyDomainService;

    /**
     * 分页查询用户API密钥存储表
     */
    @PostMapping("/page")
    public Result<PageResult<UserApiKeyResponseVO>> page(@RequestBody UserApiKeyRequestPageVO requestPageVO) {
        return Result.success(userApiKeyDomainService.page(requestPageVO));
    }

    /**
     * 新增用户API密钥存储表
     */
    @PostMapping("/create")
    public Result<Boolean> create(@RequestBody UserApiKeyRequestVO requestVO) {
        return Result.success(userApiKeyDomainService.insert(requestVO));
    }

    /**
     * 修改用户API密钥存储表
     */
    @PostMapping("/update")
    public Result<Boolean> update(@RequestBody UserApiKeyRequestVO requestVO) {
        return Result.success(userApiKeyDomainService.update(requestVO));
    }

    /**
     * 删除用户API密钥存储表
     */
    @DeleteMapping("/delete/{id}")
    public Result<Boolean> delete(@PathVariable("id") Integer id) {
        return Result.success(userApiKeyDomainService.delete(id));
    }

    /**
     * 获取用户API密钥存储表详情
     */
    @GetMapping("/get/{id}")
    public Result<UserApiKeyResponseVO> get(@PathVariable("id") Integer id) {
        return Result.success(userApiKeyDomainService.get(id));
    }
}
